package com.yanqu.road.server.cmd.activity.commonsupport.group;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.CommonUnionSupportProto;
import com.yanqu.road.server.cmd.CrossUnionCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.activity.commonsupport.CommonSupportActivity;
import com.yanqu.road.server.manager.activity.commonsupport.CommonSupportMgr;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.server.protocol.Protocol;
import com.yanqu.road.utils.YanQuMessageUtils;

@Cmd(code = Protocol.C_COMMON_UNION_GROUP_SUPPORT_LIST, desc = "获取支持列表(商会分组)")
public class CrossGetUnionGroupSupportListCmd extends CrossUnionCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {

        CommonUnionSupportProto.GetUnionSupportListReq req = CommonUnionSupportProto.GetUnionSupportListReq.parseFrom(packet.getBytes());
        CommonSupportActivity activity = CommonSupportMgr.getActivity(req.getActivityId(), groupId);
            if(activity != null){
            MessageHelper.sendPacket(serverId, packet.getPlayerId(),
                    YanQuMessageUtils.buildMessage(Protocol.U_COMMON_UNION_SUPPORT_LIST, activity.getSupportList(packet.getPlayerId())));
        }else {
            MessageHelper.sendPacket(serverId, packet.getPlayerId(),
                    YanQuMessageUtils.buildMessage(Protocol.U_COMMON_UNION_SUPPORT_LIST, CommonUnionSupportProto.GetUnionSupportListResp.newBuilder().setRet(GameErrorCode.E_ACTIVITY_NO_FOUND)));
        }
    }

    @Override
    public void sendData() {

    }
}
